//
//  MGTableViewManage.h
//  Express
//
//  Created by lhongl on 2025/9/25.
//  Copyright © 2025 QM. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class MGItem, MGSection;
NS_ASSUME_NONNULL_BEGIN

@interface MGTableViewManage : NSObject

@property (nonatomic, weak) UITableView *tableView;
@property (nonatomic, strong, readonly) NSArray <MGSection *> *sections;

- (instancetype)init UNAVAILABLE_ATTRIBUTE;
+ (instancetype)new UNAVAILABLE_ATTRIBUTE;

- (instancetype)initTableViewManageWithTableView:(__kindof UITableView *)tableView;

#pragma mark - 注册cell
- (void)registerCellWitNibName:(NSString *)nibName;
- (void)registerCellWitClass:(Class)cellClass;

#pragma mark - 注册header footer
- (void)registerHeaderFooterWitNibName:(NSString *)nibName;
- (void)registerHeaderFooterWitClass:(Class)aClass;

#pragma mark - 添加数据源
- (void)addSection:(MGSection *)section;
- (void)addSections:(NSArray<MGSection *> *)sections;
- (void)addSection:(MGSection *)section atIndex:(NSInteger)index;

#pragma mark - 删除数据源
- (void)removeSectionAtIndex:(NSInteger)index;
- (void)removeAllSections;
- (void)removeSectionsWithSections:(NSArray <MGSection *>*)sections;
- (void)removeSection:(MGSection *)section;

#pragma mark - 替换数据源
- (void)replaceSectionWithIndex:(NSUInteger)index section:(MGSection *)section;

#pragma mark - 刷新
- (void)reloadRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation API_AVAILABLE(ios(3.0));
- (void)reloadData;
@end

NS_ASSUME_NONNULL_END
